Technical Field
The invention relates to a video encoding method and a video encoding device using the same.
Related Art
Generally, when a segment of video is to be encoded, the video is divided into a plurality of frames, where each frame includes a plurality of slices, each slice includes a plurality of macroblocks, and each macroblock is further divided into one or a plurality of blocks. When a temporal redundancy between the frames is calculated, a motion vector between a current frame and a reference frame is calculated. Calculation of the motion vector is to use pixel values on the reference frame to predict a macroblock of the current frame, and a prediction result is processed with discrete cosine transform, quantization, run length coding and entropy coding. When a motion vector of a macroblock in the current frame is calculated, pixel values in a corresponding search window in the reference frame are obtained. Generally, the reference frame is stored in a memory, and when the motion vector is calculated, the corresponding search window is read from the memory.
FIG. 1 is a schematic diagram of reading a search window.
Referring to FIG. 1, a current frame 110 includes macroblocks 111 and 112. A reference frame 120 includes search windows 121 and 123. When a motion vector of the macroblock 111 is calculated, the search window 121 has to be read from the memory. When a motion vector of the macroblock 112 is calculated, the search window 123 has to be read from the memory. A region 122 is an overlapped portion between the search window 121 and the search window 123. Therefore, after the motion vector of the macroblock 111 is calculated, the motion vector of the macroblock 112 may be calculated as long as the portion of the search window 123 that is not overlapped to the search window 121 is read. After the macroblocks of the same row are encoded, the search window 121 is probably not in the memory. Therefore, when the motion estimation is executed on the macroblocks of a next row, a search window has to be further read from the memory, and such search window probably partially overlapped to the search window 121. In this way, a part of the pixel values in the search window is read twice, which may increase a bandwidth demand of the memory.
Calculation of the motion vectors requires a large amount of computations and a large memory bandwidth. Therefore, how to decrease a bandwidth demand of memory and increase a video encoding speed is an important issue to be studied in the related field.